package Exception;

//类声明，声明一个Exception的子类NoLowerLetter
class NoLowerLetter extends Exception {
    public void print() {
        System.out.printf("%c", '#');
    }
}

//类声明，声明一个Exception的子类NoDigit
class NoDigit extends Exception {
    public void print() {
        System.out.printf("%c", '*');
    }
}

class People {
    void printLetter(char c) throws NoLowerLetter {
        if (c < 'a' || c > 'z') {
            NoLowerLetter noLowerLetter = new NoLowerLetter();
            //创建NoLowerLetter类型对象
            throw new NoLowerLetter();
            //抛出noLowerLetter
        } else {
            System.out.print(c);
        }
    }

    void printDigit(char c) throws NoDigit{
        if (c < '1' || c > '9') {
            NoDigit noDigit = new NoDigit();
            //创建NoDigit类型对象
            throw new NoDigit();
            //抛出noDigit
        } else {
            System.out.print(c);
        }
    }
}

public class demo5 {
    public static void main(String[] args) {
        People people = new People();
        for (int i = 0; i < 128; i++) {
            try {
                people.printLetter((char) i);
            } catch (NoLowerLetter e) {
                e.print();
            }
        }
        for (int i = 0; i < 128; i++) {
            try {
                people.printDigit((char) i);
            } catch (NoDigit e) {
                e.print();
            }
        }

    }
}